{% extends "layout.html" %}

{% block title %} 登录 {% endblock %}


{% block body %}

   <link type="text/css" rel="stylesheet" href="{{ url_for("static",filename='css/sign_in.css') }}">


    <div class="container" style="margin-top: 300px; ">
        <div class="row">
            <div class="col-md-offset-4 col-md-4 ">
                <!--h2 class=" text-center"><img src="{{ url_for("static",filename='img/1.jpg') }}" style="height:88px;margin: 0 auto"/></h2>
                <h2 class="text-center text-success"><strong>昆仑镜 · 洞见一切</strong></h2><br-->
                <p><input class="sign_in_input" id="username" placeholder="请输入用户名" autofocus></p>
                <p><input class="sign_in_input" id="password" type="password" placeholder="请输入密码" ></p>
                <button class="btn btn-lg btn-warning btn-block" style="opacity: 0.9" onclick="sign_in()">登  录</button>

            </div>
        </div>
    </div>


    <script>
        function sign_in(){
            var username = $('#username')[0].value;
            var password = $('#password')[0].value;
            if(username.length==0) {
                my_alert("请输入用户名！")
                return;
            }
            if(password.length==0) {
                my_alert("请输入密码！")
                return;
            }

            var url =   '/sign_in/username='+username+'&password='+password;
            $.getJSON(url, function (data) {
                if(data.result==0){
                     my_alert("验证错误，请输入正确的用户名和密码！")
                }else{
                    $.cookie('username',username);
                    my_alert("登录成功！");
                    window.location.href = "/grzx";
                }
            });
        }
    </script>
{% endblock %}
